package com.example.loggingservice.controller;

import com.example.loggingservice.entity.OperationLog;
import com.example.loggingservice.service.LoggingService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/logs")
@RequiredArgsConstructor
public class LogController {
    private final LoggingService loggingService;

    @GetMapping
    public ResponseEntity<List<OperationLog>> getLogs(
            @RequestParam(required = false) Long userId,
            @RequestParam(required = false) String action) {
        return ResponseEntity.ok(loggingService.getLogs(userId, action));
    }
}